#ifndef CHATDIALOG_H
#define CHATDIALOG_H
#include "chatuserwid.h"
#include <QDialog>
#include <QMouseEvent>
#include "global.h"
#include "statewidget.h"
#include "searchdata.h"
#include <QListWidgetItem>
namespace Ui {
class ChatDialog;
}

class ChatDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ChatDialog(QWidget *parent = nullptr);
    ~ChatDialog();

    void showSearch(bool show);
    void addChatUserList();  //前期的测试函数
    void AddLBGroup(StateWidget* sw);
    void ClearLabelState(StateWidget *lb);

    void loadMoreChatUser();
    void loadMoreConUser();
    void SetSelectChatItem(int uid = 0);
    void SetSelectChatPage(int uid = 0);
    void UpdateChatMsg(std::vector<std::shared_ptr<TextChatData> > msgdata);
protected:
    bool eventFilter(QObject* watch,QEvent* event);
    void handleGlobalMousePress(QMouseEvent* event);
public slots:
    void slot_item_clicked(QListWidgetItem *item);
    void slot_loading_chat_user();
    void slot_side_chat();
    void slot_side_contact();
    void slot_text_changed(const QString& str);

    void slot_friend_apply(std::shared_ptr<AddFriendApply> apply);
    void slot_auth_rsp(std::shared_ptr<AuthRsp> authrsp);
    void slot_add_auth_firend(std::shared_ptr<AuthInfo> authinfo);
    void slot_switch_friend_info_page(std::shared_ptr<UserInfo> info);
    void slot_switch_apply_friend_page();
    void slot_jump_chat_item_1(std::shared_ptr<UserInfo> info);
    void slot_jump_chat_item_2(std::shared_ptr<UserInfo> info);
    void slot_append_send_chat_msg(std::shared_ptr<TextChatData> info);
    void slot_text_chat_msg(std::shared_ptr<TextChatMsg>);
private:
    Ui::ChatDialog *ui;
    QList<StateWidget*> _lb_list;
    ChatUIMode _mode;
    ChatUIMode _state;
    bool _b_loading;
    QMap<int, QListWidgetItem*> _chat_items_added;
    int _cur_chat_uid;

};

#endif // CHATDIALOG_H
